
#ifndef GD32E230C_BSP_H
#define GD32E230C_BSP_H

#ifdef __cplusplus
 extern "C" {
#endif

// #include "sys.h"
#include "gd32e23x.h"

#define KEY1   gpio_input_bit_get(GPIOF,GPIO_PIN_6)
#define KEY2   gpio_input_bit_get(GPIOF,GPIO_PIN_7)

#define CLOCK_TASK_CYCLE  500 //ms
#define MAIN_TASK_CYCLE   10 //ms

#define LED_FLASH_CYCLE   500 //ms

#define FMC_PAGE_SIZE               ((uint16_t)0x400U)  //flashһҳ1K�ֽ�

#define FMC_WRITE_AMTALL_START_ADDR  ((uint32_t)0x0800F400U)
#define FMC_WRITE_AMTALL_END_ADDR	 ((uint32_t)0x0800F7FFU)

#define FMC_WRITE_BASE_START_ADDR    ((uint32_t)0x0800F800U)
#define FMC_WRITE_BASE_END_ADDR	     ((uint32_t)0x0800FBFFU)

#define FMC_WRITE_WORK_START_ADDR    ((uint32_t)0x0800FC00U)
#define FMC_WRITE_WORK_END_ADDR		 ((uint32_t)0x0800FFFFU)


extern uint16_t prescaler_a, prescaler_s;

/* configure COM port */
void Usart0_Init(uint32_t bd);
void Init_SV(void);
void Init_Key(void);
void init_WakeUpPin(void);

void read_flash(uint32_t rd_addr,uint8_t *pdata,uint32_t rd_len);
void write_flash(uint32_t wr_addr,uint32_t *data, uint32_t data_len);

void BKP_WriteBackupRegister(uint32_t BKP_DR, uint32_t Data);
uint32_t BKP_ReadBackupRegister(uint32_t BKP_DR);

#ifdef __cplusplus
}
#endif

#endif /* GD32E230C_EVAL_H */

